home *** CD-ROM | disk | FTP | other *** search
- From: boukanov@hadron.fi.uib.no (Igor Boukanov)
- Message-ID: <4gf60c$cdt@ugress.uib.no>
- X-Original-Date: 21 Feb 1996 13:17:00 GMT
- Path: in2.uu.net!bounce-back
- Date: 21 Feb 96 13:54:01 GMT
- Approved: fjh@cs.mu.oz.au
- Newsgroups: comp.std.c++
- Subject: Re: Namespace extension
- Organization: Fysisk institutt, Universitetet i Bergen
- References: <4g2aj2$bko@ugress.uib.no> <4g5e4v$cvi@peippo.cs.tut.fi>
- X-Newsreader: TIN [version 1.2 PL2]
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBFAgUBMSsxvuEDnX0m9pzZAQGhNwF/Vq1pMnJopwcexF0/O3DFSpHZAAF6H6Pe
- uHlPHAipklQ6J6POOdMxBTi6w586/df0
- =ZmFB
-
- Pulkkinen Esa (esap@cs.tut.fi) wrote:
- > This raises immediately the following questions:
-
- > template <class T> namespace { // an unnamed namespace template - allowed?
- > int i; // how many copies of this will be in the program?
- > // what's the syntax for accessing the variable?
- > // i<T> ? <T>::i ?
- > typedef vector<T>::iterator vector_iterator; // is this the same
- > // as a typedef template?
- > }
-
- From the general point of view such lines would not be allowed becouse
- they can be written as
- template <class T> namespace unique {
- ...
- }
- using namespace unique<T>;
-
- but namespace unique is predefined and template names can not be
- overloaded.
-
-
- > template <class T> namespace X { int f(); }
-
- > template <class T> using X<T>::f(); // Allowed?
- > template <class T> using namespace X<T>; // Allowed?
-
- > [points to justify namespace templates removed]
-
- I agree that such lines should not be allowed. But this would not be another
- rule about template namespace, I propose to extend the template to allow
- template namespace declarations, NOT a template "using" declarations.
- And this does not prohibit next lines:
-
- template<class T> namespace A {
- void f(T);
- ...
- }
-
- template<class T> namespace B {
- using A<T>;
- ...
- void g(T t) { return f(t); } // call A<T>::f
- }
-
- > > 3. It makes C++ easy to study, because somebody will have to know only
- > >the general idea about templates and how to apply them to any C++ elements
- > >(function, class, namespase,...).
-
- > This would only be true if also typedef templates and union templates
- > were introduced too.
- > --
-
- I agree that reason 3 should be removed. But here is another reason:
- Non-template class with only public static members can be replaced by
- namespace declaration. But why template class with only public static
- members could not be replaced by corresponding template namespace?
-
- --
- Regards, Igor Boukanov (igor.boukanov@fi.uib.no).
- ---
- [ To submit articles: try just posting with your news-reader.
- If that fails, use mailto:std-c++@ncar.ucar.edu
- FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
- Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu.
- ]
-